import request from "./request.js";
const isProduction = import.meta.env.PROD;

// 远端服务
export const hello2 = () => {
  return request({
    url: isProduction ? "/hello2" : "/api/hello2",
    method: "post",
    data: { type: 1 },
  });
};

// 登入
export const login = (data) => {
  return request({
    url: "/api/login",
    method: "post",
    loading: true,
    data,
  });
};

// 获取see Token
export const seeToken = (data) => {
  return request({
    url: "/api/sse/token",
    method: "post",
  });
};

// 获取房间声网直播信息
export const agoraToken = (data) => {
  return request({
    url: "/api/room/agora/token",
    method: "post",
  });
};

// 获取房间牌局详情
export const roomInfo = (data) => {
  return request({
    url: "/api/room/info",
    method: "post",
  });
};

// 开始游戏
export const gameStart = (data) => {
  return request({
    url: "/api/room/game/start",
    method: "post",
    loading: true,
  });
};

// 结束游戏
export const gameSettle = (data) => {
  return request({
    url: "/api/room/game/settle",
    method: "post",
    loading: true,
    data,
  });
};

// 读牌上传
export const upload4Test = () => {
  return request({
    // url: "/api/room/game/card/upload4Test", // 无硬件测试
    url: "/api/room/game/card/upload",
    method: "post",
    loading: true,
  });
};

// 下一轮
export const roundNext = () => {
  return request({
    url: "/api/room/game/round/next",
    method: "post",
    loading: true,
  });
};

// 踢人
export const roomKick = (data) => {
  return request({
    url: "/api/room/kick",
    method: "post",
    loading: true,
    data,
  });
};

// 设备录入（本地）
export const deviceList4Test = () => {
  return request({
    url: "/api/device/list",
    // url: "/api/device/list4Test", // 无硬件测试
    method: "post",
    loading: true,
  });
};

// 设备录入（远端）
export const deviceList = () => {
  return request({
    url: "/api/device/room/list",
    method: "post",
    loading: true,
  });
};

// 设备录入数据提交
export const deviceUpload = (data) => {
  return request({
    url: "/api/device/upload",
    method: "post",
    loading: true,
    data,
  });
};

// 设置颜色
export const lightSet = (data) => {
  return request({
    url: "/api/device/light/set",
    method: "post",
    loading: true,
    data,
  });
};
